/**
 * Created by Shaobing on 24/05/2014.
 */
public class FizzBuzz {
    public static void run(int n) {
        for(int i = 1; i <= n; i++){
            System.out.println(fizzBuzz(i));
        }
    }

    public static String fizzBuzz(Integer input) {

        boolean isMultipleOfFive = multipliesBy(input, 5);
        boolean isMultipleOfThree = multipliesBy(input, 3);
        if(isMultipleOfThree && isMultipleOfFive){
            return "FizzBuzz";
        }
        if(isMultipleOfThree){
            return "Fizz";
        }

        if(isMultipleOfFive){
            return "Buzz";
        }

        return input.toString();
    }

    private static boolean multipliesBy(int input, int factor){
        return input % factor == 0;
    }
}
